{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2e0fad63",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 在notebook中学习logging模块\n",
    "import logging\n",
    "logger = logging.getLogger(__name__)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "93098bca",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "# 仅保存到文件，不输出到控制台\n",
    "# logging.basicConfig(filename='example.log', encoding='utf-8', level=logging.DEBUG)\n",
    "logging.basicConfig(filename='example.log', filemode='w', level=logging.DEBUG)\n",
    "\n",
    "logger.debug('This message should go to the log file')\n",
    "logger.info('So should this')\n",
    "logger.warning('And this, too')\n",
    "logger.error('And non-ASCII stuff, too, like Øresund and Malmö')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7e12345f",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
